//##############################################################################
// DRAG AND DROP

form .form-row {
    &[class*="file"],
    &[class*="folder"],
    &[class*="img"],
    &[class*="image"],
    &[class*="visual"] {
        .related-widget-wrapper-link {
            display: none;
        }
    }
    .filer-widget + .related-widget-wrapper-link,
    .filer-widget + * + .related-widget-wrapper-link {
        display: none;
    }
    .related-widget-wrapper:has(.filer-widget,.filer-dropzone) {
        width: 100%;
    }
    .filer-dropzone {
        @include clearfix;
        position: relative;
        min-width: 215px;
        border: solid 1px $gray-lighter;
        border-radius: $border-radius-normal;
        background-color: $gray-lightest;
        box-sizing: border-box !important;
        .z-index-fix {
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
        }
        &.dz-drag-hover {
            background-color: $color-primary;
            filter: brightness(1.5);
            border: solid 2px $color-primary !important;
            .z-index-fix {
                z-index: 1;
            }
            .dz-message {
                opacity: 1;
                display: block !important;
                visibility: visible;
            }
            .filerFile {
                display: none;
            }
            .dz-message, .dz-message .icon {
                color: $color-primary !important;
            }
        }
        &.dz-started .fileUpload {
            display: none;
        }
        .dz-preview {
            width: 100%;
            min-height: auto;
            margin-right: 0;
            margin-bottom: 0;
            margin-left: 0;
            padding-bottom: 10px;
            border-bottom: solid 1px $gray-lighter;
            &.dz-error {
                position: relative;
                .dz-error-message {
                    display: none;
                }
                &:hover .dz-error-message {
                    display: block;
                }
            }
            .dz-details {
                min-width: calc(100% - 80px);
                max-width: calc(100% - 80px);
                margin-top: 7px;
                margin-left: 40px;
                padding: 0;
                opacity: 1;
                .dz-filename,
                .dz-filename:hover,
                .dz-size {
                    float: left;
                    text-align: left;
                    span {
                        color: $gray;
                        border: 0 !important;
                        background-color: transparent !important;
                    }
                }
            }
            .dz-remove {
                background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='bi bi-trash' viewBox='0 0 16 16'%3E%3Cpath d='M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6Z'/%3E%3Cpath d='M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1ZM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118ZM2.5 3h11V2h-11v1Z'/%3E%3C/svg%3E%0A");
                background-size:contain;
                display: inline-block;
                position: absolute;
                top: 7px;
                right: 25px;
                font: 0/0 a;
                width: 18px;
                height: 18px;
            }
            .dz-error-message {
                top: 65px;
                left: 0;
                width: 100%;
            }
            .dz-success-mark,
            .dz-error-mark {
                top: 5px;
                right: 0;
                left: auto;
                margin-top: 0;
                &:before {
                    color: $gray;
                }
                svg {
                    display: none;
                }
            }
            .dz-success-mark {
                // Check icon
                width: 16px;
                height: 16px;
                background-image: url("data:image/svg+xml,%3Csvg width='13' height='13' viewBox='0 0 1792 1792' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%2370bf2b' d='M1412 734q0-28-18-46l-91-90q-19-19-45-19t-45 19l-408 407-226-226q-19-19-45-19t-45 19l-91 90q-18 18-18 46 0 27 18 45l362 362q19 19 45 19 27 0 46-19l543-543q18-18 18-45zm252 162q0 209-103 385.5t-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z'/%3E%3C/svg%3E%0A");
                background-size: contain;
            }
            .dz-error-mark {
                // Remove icon
                background-image: url("data:image/svg+xml,%3Csvg width='13' height='13' viewBox='0 0 1792 1792' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23dd4646' d='M1277 1122q0-26-19-45l-181-181 181-181q19-19 19-45 0-27-19-46l-90-90q-19-19-46-19-26 0-45 19l-181 181-181-181q-19-19-45-19-27 0-46 19l-90 90q-19 19-19 46 0 26 19 45l181 181-181 181q-19 19-19 45 0 27 19 46l90 90q19 19 46 19 26 0 45-19l181-181 181 181q19 19 45 19 27 0 46-19l90-90q19-19 19-46zm387-226q0 209-103 385.5t-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z'/%3E%3C/svg%3E%0A");
                width: 16px;
                height: 16px;
                background-size: contain;
            }
            &.dz-image-preview,
            &.dz-file-preview {
                background-color: transparent;
                .dz-image {
                    overflow: hidden;
                    width: 36px;
                    height: 36px;
                    border: solid 1px $gray-lighter;
                    border-radius: 0;
                    img {
                        width: 100%;
                        height: auto;
                    }
                }
            }
            .dz-progress {
                top: 18px;
                left: 0;
                width: calc(100% - 40px);
                height: 10px;
                margin-left: 40px;
            }
        }
        .dz-message {
            float: right;
            color: $gray-dropzone;
            width: 100%;
            margin: 15px 0 0;
        }
        .icon {
            position: relative;
            top: 3px;
            color: $gray-dropzone;
            font-size: 24px;
            margin-right: 10px;
        }
        .filerFile .related-lookup {
            @include button-variant($btn-action-color, var(--primary), $btn-action-border, true);
            float: left !important;
            overflow: hidden;
            // makes true that button has correct height #668
            line-height: $font-size-normal;
            width: auto !important;
            height: auto !important;
            padding: 10px 20px !important;
            margin-top: 24px;
            margin-left: 10px;
            text-align: center !important;
            cursor: pointer;
            .cms-icon {
                color: $white;
                font-size: 17px;
                margin: 0 10px 0 0;
                vertical-align: middle;
            }
            &:before {
                display: none;
            }
            .choose-file,
            .replace-file,
            .edit-file {
                color: $white;
                margin: 0;
            }
            .replace-file {
                display: none;
            }
            &.edit {
                display: none;
            }
            &.related-lookup-change {
                @include button-variant($btn-default-color, $btn-default-bgcolor, $btn-default-border, true);
                float: right !important;
                padding: 5px 0 !important;
                width: 36px !important;
                height: 36px !important;
                &:focus {
                    background-color: $white !important;
                }
                span {
                    text-align: center;
                    line-height: 24px;
                }
                .cms-icon {
                    color: $btn-default-color;
                    margin-right: 0 !important;
                }
                .choose-file {
                    display: none;
                }
                .replace-file {
                    display: block;
                }
                &.lookup {
                    display: block !important;
                }
                &.edit {
                    display: block;
                }
            }
        }
        // makes sure that filer clear button has correct size #669
        .filerClearer {
            width: 36px !important;
            height: 36px !important;
            color: $color-danger;
        }
        .filerFile {
            position: absolute;
            top: 9px;
            // required for django CMS <= 3.1 #673
            left: 20px;
            width: calc(100% - 40px);
            img[src*=nofile] {
                background-color: $white;
            }
            // make sure that text crops if there is not enough space #670
            span:not(:empty):not(.choose-file):not(.replace-file):not(.edit-file) {
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                width: calc(100% - 260px);
                height: 80px;
                line-height: 80px;
            }
            // required for django CMS <= 3.1 #673
            img {
                width: 80px;
                height: 80px;
                margin-right: 10px;
                border: solid 1px $gray-lighter;
                border-radius: 0;
                vertical-align: top;
                &[src*="nofile"] {
                    box-sizing: border-box;
                    margin-right: 0;
                    border: solid 1px $gray-lighter;
                    border-radius: 0;
                }
            }
            // required for django CMS <= 3.1
            a {
                box-sizing: border-box;
                padding-top: 10px !important;
            }
            // required for django CMS <= 3.1 #673
            span {
                display: inline-block;
                color: $gray;
                font-weight: normal;
                margin-bottom: 6px;
                text-align: left;
                &:empty + .related-lookup {
                    float: none !important;
                    margin-left: 0 !important;
                }
            }
            // required for django CMS <= 3.1 #673
            a.filerClearer {
                @include button-variant($btn-default-color, $btn-default-bgcolor, $btn-default-border, true);
                float: right;
                padding: 5px 0  !important;
                margin: 24px 0 0 10px;
                width: 36px;
                height: 36px;
                text-align: center;
                cursor: pointer;
                span:before {
                    color: $color-danger !important;
                }
                span {
                    text-align: center;
                    line-height: 24px;
                }
            }

        }
        &.filer-dropzone-mobile {
            .filerFile {
                text-align: center;
            }
            .dz-message {
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                // make sure that drag and drop widget looks nice on mobile #670
                margin-top: 75px;
            }
            &.js-object-attached .filerFile {
                text-align: center;
                &.js-file-selector {
                    @media screen and (max-width: $screen-tablet-filer) {
                        .description_text {
                            text-overflow: ellipsis;
                            width: calc(100% - 250px);
                            overflow: hidden;
                        }
                    }
                    >span:not(.choose-file):not(.replace-file):not(.edit-file), .dz-name {
                        width: calc(100% - 250px);
                    }
                }
            }

        }
        &.filer-dropzone-folder .filerFile {
            top: 8px;
            #id_folder_description_txt {
                float: left;
            }
        }

        @media (max-width: 767px) {
            flex-grow: 1;
        }

    }
}

.filer-dropzone {
    min-height: 100px !important;
    .dz-upload {
        height: 5px;
        background-color: $color-primary;
    }
    .dz-name {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        max-width: calc(100% - 145px);
    }
    .dz-thumbnail {
        display: inline-block;
        overflow: hidden;
        vertical-align: top;
        width: 80px;
        height: 80px;
        margin-right: 10px;
        border: solid 1px $gray-lighter;
        border-radius: 3px;
        background: $white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath fill='%232980b9' d='M5 2c-1.105 0-2 .9-2 2v18c0 1.1.895 2 2 2h14c1.105 0 2-.9 2-2V8l-6-6z'/%3E%3Cpath fill='%233498db' d='M5 1c-1.105 0-2 .9-2 2v18c0 1.1.895 2 2 2h14c1.105 0 2-.9 2-2V7l-6-6z'/%3E%3Cpath fill='%232980b9' d='m21 7-6-6v4c0 1.1.895 2 2 2z'/%3E%3C/svg%3E");
        background-size: contain;
        img {
            background: $white;
            &[src=""],
            &:not([src]) {
                width: 104%;
                height: 104%;
                margin: -2%;
            }
        }
    }
}

.filer-dropzone-info-message {
    position: fixed;
    bottom: 35px;
    left: 50%;
    z-index: 2;
    text-align: center;
    width: 270px;
    max-height: 300px;
    overflow-y: auto;
    margin: -50px 0 0 -150px;
    padding: 15px 15px 0;
    border-radius: $border-radius-base;
    background: $white;
    box-shadow: $base-box-shadow;
    .icon {
        font-size: 35px;
        color: $color-primary;
    }
    .text {
        margin: 5px 0 10px;
    }
}
.filer-dropzone-upload-info {
    margin-top: 10px;
    // make sure that file name on upload progress is cut #675
    .filer-dropzone-file-name {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
    &:empty {
        margin-top: 0;
    }
}
.filer-dropzone-progress {
    height: 5px;
    margin-top: 5px;
    background-color: $color-primary;
}

.filer-dropzone-upload-welcome .folder {
    color: $color-primary;
    padding: 10px 0 0;
    margin: 0 -15px;
    border-top: solid 1px $gray-lighter;
    img,
    span {
        vertical-align: middle;
    }
    img {
        margin-right: 5px;
    }
    .folder-inner {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        padding: 0 10px;
    }
}

.filer-dropzone-cancel {
    padding-top: 10px;
    border-top: solid 1px $gray-lighter;
    margin: 15px -15px 10px;
    a {
        font-size: $font-size-small;
        color: $gray !important;
    }
}
.filer-dropzone-upload-success,
.filer-dropzone-upload-canceled {
    margin: 0 -15px 10px;
}

.filer-dropzone-upload-count {
    padding-bottom: 10px;
    margin: 10px -15px;
    border-bottom: solid 1px $gray-lighter;
}
